package com.zhangdi.demo.jpa.controller;

import com.zhangdi.demo.jpa.entity.A;
import com.zhangdi.demo.jpa.entity.B;
import com.zhangdi.demo.jpa.impl.ATestService;
import com.zhangdi.demo.jpa.vo.QVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashSet;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("jpatest")
public class Controller {
    @Autowired
    ATestService service;

    @GetMapping("/save")
    public void save(){
        A a = new A();
        a.setName("test"+System.currentTimeMillis());
        a.setBlist(new HashSet<>());

        B b = new B();
        b.setNotes("bbbbb");
        b.setTimes("2021-06-16");
        b.setA(a);

        a.getBlist().add(b);

        service.save(a);
    }
}
